﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSLib.Parsing.Common;

namespace LuaLanguageExtension.Parsing.Search
{
    public static class RecognizedTokenExtension
    {
        /*public static int GetGlobalStartPosition(this RecognizedToken token, ITextSnapshot snapshot)
        {
            int result = -1;
            if (token != null)
            {
                ITextSnapshotLine line = snapshot.GetLineFromLineNumber(token.Token.Line - 1);
                result = line.Start.Position + token.Token.CharPositionInLine;
            }
            return result;
        }

        public static Span GetSpan(this RecognizedToken token, ITextSnapshot snapshot)
        {
            ITextSnapshotLine recTokenLine = snapshot.GetLineFromLineNumber(token.Token.Line - 1);
            return new Span(recTokenLine.Start.Position + token.Token.CharPositionInLine, token.Token.Text.Length);
        }

        public static ElementPosition GetElementPosition(this RecognizedToken token, ITextSnapshot snapshot)
        {
            int tokenStartPosition = token.GetGlobalStartPosition(snapshot);
            ITextSnapshotLine line = snapshot.GetLineFromPosition(tokenStartPosition);
            ElementPosition pos = new ElementPosition(line.LineNumber + 1, line.Start.Position - tokenStartPosition);
            return pos;
        }*/

    }
}
